﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication1
{
    public class _404NotFound:IHttpModule
    {
        public void Dispose()
        {
            //throw new NotImplementedException();
        }

        public void Init(HttpApplication context)
        {
            context.AuthorizeRequest += context_AuthorizeRequest;
        }

        void context_AuthorizeRequest(object sender, EventArgs e)
        {
            var request = HttpContext.Current.Request;
            var response = HttpContext.Current.Response;
            response.Write(String.Format("<h3>PhysicalApplicationPath:{0}</h3>", request.PhysicalApplicationPath));
            response.Write(String.Format("<h3>PhysicalPath:{0}</h3>", request.PhysicalPath));
            response.Write(String.Format("<h3>Url:{0}</h3>", request.Url.ToString()));
            response.Write(String.Format("<h3>Url.IsFile:{0}</h3>", request.Url.IsFile));
            response.Write(String.Format("<h3>Url.AbsoluteUri:{0}</h3>", request.Url.AbsoluteUri));
            response.Write(String.Format("<h3>Url.AbsolutePath:{0}</h3>", request.Url.AbsolutePath));
            response.Write(String.Format("<h3>Url.LocalPath:{0}</h3>", request.Url.LocalPath));

            if (!System.IO.File.Exists(request.PhysicalPath))
            {
                //response.RedirectPermanent("http://error.5173.com", true);
            }

        }
    }
}